package com.example.doctor.controller;

import com.example.common.support.Result;
import com.example.doctor.dto.req.GetPhoneCode;
import com.example.doctor.dto.req.GetUserTel;
import com.example.doctor.dto.req.GetWxInfoR;
import com.example.doctor.dto.req.SmsLogin;
import com.example.doctor.service.UserLoginService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author sifan
 * @PackagName:com.example.doctor.controller
 * @ClassName: UserLoginController
 * @Description:
 * @date:2021/1/18 11:58
 */

@RestController
@Api(tags = "医生端登录相关")
@RequestMapping("/api/Login")
public class UserLoginController {


    @Resource
    UserLoginService userLoginService;


    @ApiOperation(value = "获取短信验证码")
    @PostMapping("/SendCode")
    public Result<HashMap> SendCode(@RequestBody GetPhoneCode getPhoneCode) {
        boolean code = userLoginService.getPhoneCode(getPhoneCode);
        HashMap hashMap = new HashMap();
        hashMap.put("Send", code);
        return Result.success(hashMap);
    }

    @ApiOperation(value = "短信登录")
    @PostMapping("/DoSMSLogin")
    public Result<HashMap<String, Object>> DoSMSLogin(@RequestBody SmsLogin smsLogin) {
        HashMap<String, Object> hashMap = userLoginService.smsLogin(smsLogin);
        return Result.success(hashMap);
    }


    @ApiOperation(value = "小程序登录")
    @PostMapping("/getWxInfoR")
    public Result<HashMap<String, Object>> getWxInfoR(@RequestBody GetWxInfoR getWxInfoR) {
        HashMap<String, Object> hashMap = userLoginService.getWxInfoR(getWxInfoR);
        return Result.success(hashMap);
    }


    @ApiOperation(value = "获取电话号码")
    @PostMapping("/GetUserTel")
    public Result<HashMap<String, Object>> GetUserTel(@RequestBody GetUserTel getUserTel) {
        HashMap<String, Object> hashMap = userLoginService.GetUserTel(getUserTel);
        return Result.success(hashMap);

    }


}
